using UnityEngine;

public class PoolRecycler : MonoBehaviour
{
	[SerializeField]
	private Transform m_RefTrans;

	public Color gizmoColor = new Color(1f, 0f, 0f, 0.5f);

	private BoxCollider m_boxCollider;

	private PocketTrigger m_RefTrigger;

	public void SetTrigger(PocketTrigger _Trigger)
	{
		m_RefTrigger = _Trigger;
	}

	private void Start()
	{
		m_boxCollider = base.gameObject.GetComponent<BoxCollider>();
	}

	public Vector3 getPosition()
	{
		return m_boxCollider.center;
	}

	private void OnTriggerEnter(Collider col)
	{
		PoolBall component = col.GetComponent<PoolBall>();
		if (!col.CompareTag("Ball"))
		{
			return;
		}
		GameManager.Rules.PotBall(component, m_RefTrigger.PocketIndex);
		if (component.ballType != BallType.JIANGYOU)
		{
			Pools.StorageRack.Add(component);
			if (PocketTrigger.pocketTriggerBallList.Contains(col.GetInstanceID()))
			{
				PocketTrigger.pocketTriggerBallList.Remove(col.GetInstanceID());
			}
		}
		else
		{
			UnityEngine.Object.Destroy(component.gameObject);
		}
	}
}
